package com.java.design.observer.customer;

/**
 * 订阅天气的订阅者*
 * @author Tony *
 */
public class CurrentConditionsDisplay implements ObServer,Display{

    private float temp;

    private float humidity;

    private final Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("current conditions: " + temp +"F degrees and " + humidity + "% humidity");
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        display();
    }
}
